home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / smtp / ch_smtp.c next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  3.3 KB  |  133 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3. /*
  4.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  5.  *     
  6.  *
  7.  *     Copyright (C) 1979,1980,1981  University of Delaware
  8.  *     
  9.  *     Department of Electrical Engineering
  10.  *     University of Delaware
  11.  *     Newark, Delaware  19711
  12.  *
  13.  *     Phone:  (302) 738-1163
  14.  *     
  15.  *     
  16.  *     This program module was developed as part of the University
  17.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  18.  *     
  19.  *     Acquisition, use, and distribution of this module and its listings
  20.  *     are subject restricted to the terms of a license agreement.
  21.  *     Documents describing systems using this module must cite its source.
  22.  *
  23.  *     The above statements must be retained with all copies of this
  24.  *     program and may not be removed without the consent of the
  25.  *     University of Delaware.
  26.  *     
  27.  *
  28.  *     version  -1    David H. Crocker    March   1979
  29.  *     version   0    David H. Crocker    April   1980
  30.  *     version  v7    David H. Crocker    May     1981
  31.  *     version   1    David H. Crocker    October 1981
  32.  *
  33.  */
  34.  
  35. /*                  ARPANET MAIL CHANNEL                                */
  36.  
  37. #include <signal.h>
  38. #include "phs.h"
  39. #include "ch.h"
  40.  
  41. extern char *dupfpath();
  42. extern LLog *logptr;
  43.  
  44. Chan *chanptr;
  45. char obuf[BUFSIZ];        /* Buffer for status printfs */
  46.  
  47. /*      MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN     */
  48.  
  49. main (argc, argv)
  50. int       argc;
  51. char   *argv[];
  52. {
  53.     short retval;
  54.  
  55.     mmdf_init (argv[0]);
  56.     setbuf( stdout, obuf );
  57.  
  58. #ifdef RUNALON
  59.     logptr -> ll_fd = 1;
  60.     ll_init (logptr);
  61. #endif
  62.     siginit ();
  63.     signal (SIGINT, SIG_IGN);     /* always ignore interrupts             */
  64.  
  65.     if ((chanptr = ch_nm2struct (argv[0])) == (Chan *) NOTOK)
  66.     {
  67.     ll_log (logptr, LLOGTMP, "ch_smtp (%s) unknown channel", argv[0]);
  68.     exit (RP_PARM);
  69.     }
  70.     retval = ch_smtp (argc, argv);
  71.     ll_close (logptr);
  72.     exit (retval);
  73. }
  74. /* **************  (ch_) LOCAL MAIL DELIVERY  ************************ */
  75.  
  76. ch_smtp (argc, argv)              /* send to internet                   */
  77. int       argc;
  78. char   *argv[];
  79. {
  80. #ifndef RUNALON
  81.     ch_llinit (chanptr);
  82. #endif
  83. #ifdef DEBUG
  84.     ll_log (logptr, LLOGBTR, "ch_smtp()");
  85. #endif
  86.  
  87.     if (rp_isbad (qu_init (argc, argv)))
  88.     return (RP_NO);          /* problem setting-up for deliver     */
  89.     
  90.     if (rp_isbad (sm_init (chanptr)))
  91.     return (RP_NO);
  92.  
  93.     phs_note (chanptr, PHS_WRSTRT);
  94.  
  95.     if (rp_isbad (qu2sm_send ()))
  96.     return (RP_NO);          /* send the batch of outgoing mail    */
  97.  
  98.     phs_note (chanptr, PHS_WREND);
  99.  
  100.     qu_end (OK);                  /* done with Deliver function         */
  101.  
  102.     return (RP_OK);          /* NORMAL RETURN                      */
  103. }
  104.  
  105. /* */
  106.  
  107. /* VARARGS2 */
  108. err_abrt (code, fmt, b, c, d)     /* terminate ourself                  */
  109. short     code;
  110. char    fmt[],
  111.         b[],
  112.         c[],
  113.         d[];
  114. {
  115. #ifdef DEBUG
  116.     char linebuf[LINESIZE];
  117. #endif
  118.  
  119.     qu_end (NOTOK);
  120.  
  121. #ifdef DEBUG
  122.     if (rp_gbval (code) == RP_BNO || logptr -> ll_level >= LLOGBTR)
  123.     {                         /* don't worry about minor stuff      */
  124.     sprintf (linebuf, "%s%s", "err [ ABEND (%s) ]\t", fmt);
  125.     ll_log (logptr, LLOGFAT, linebuf, rp_valstr (code), b, c, d);
  126.     abort ();
  127.     }
  128. #endif
  129.     ll_close (logptr);            /* in case of cycling, close neatly   */
  130.  
  131.     exit (code);
  132. }
  133.